<%@ page language="java" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
${aier_doctype}
<html <s:property value="aier_html_xmlns" escape="false"/>>
<head>
<meta http-equiv="Content-Type" content="${aier_content_type}" />
<title><s:property value="ev_title" /></title>
<meta name="keywords" content="${aier_keyworks}" />
<meta name="description" content="${aier_description}" />
<link rel="stylesheet" href="${aier_css_url}${aier_jqui_css}/ui.css" />
<link rel="stylesheet" href="${aier_css_url}social/module/jq-msg.css" />
<link rel="stylesheet" href="${aier_css_url}jp/1.css" />
<link rel="stylesheet" href="${aier_css_url}index/fam-user-mana.css" />
<link href="${aier_css_url}jc/chosen.css" rel="stylesheet">
<link href="${aier_css_url}jq/jq.css" rel="Stylesheet" />
<link rel="stylesheet" href="${aier_css_url}comm/text.css" />
<link rel="stylesheet" href="${aier_css_url}admin/admin.css" />

<script type="text/javascript" src="${aier_js_url}j.js"></script>
<script type="text/javascript" src="${aier_js_url}b.js"></script>
<script type="text/javascript" src="${aier_js_url}jp/msg.js"></script>
<script type="text/javascript" src="${aier_js_url}jp/1.js"></script>
<script type="text/javascript" src="${aier_js_url}lib/afu.js"></script>
<script type="text/javascript" src="${aier_js_url}jp/hh/ui.js"></script>
<script type="text/javascript" src="${aier_js_url}lib/block.js"></script>
<script type="text/javascript" src="${aier_js_url}lib/arrayList.js"></script>
<script type="text/javascript" src="${aier_js_url}jc/cj.js"></script>
<script type="text/javascript" src="${aier_js_url}jq/jq.js"></script>
<script type="text/javascript" src="${aier_js_url}jq/cn.js"></script>
<script type="text/javascript" src="${aier_js_url}comm/text.js"></script>
</head>

<body style="background-color: #EEF2FB;">
    
    <div style="background-color: #EEF2FB;width: 100%;height: 700px; ">
       
        <div id="tabs">
	        <ul>
	            <li><a href="#tabs-1">管理ic卡</a></li>
	        </ul>
            <div id="tabs-1" style="height: 500px;">
                 <div class="d_content">
                    <div style="font-size: 14px;font-weight: bold;">说明：此页面的分派卡功能是直接将卡分派到指定的学校，如需分配给教师或学生，请到"学校管理"进行分配；回收卡是直接从系统中删除此卡。此功能用于公司相关人员作门禁测试。</div>
                    <div style="margin-top: 50px;font-weight: bold;">分派卡</div>
                    <div class="d_scnOut">
                        <div class="d_scname" style="margin-left: 0px;">
                            <label for="name">学校名称: </label>
                        </div>
                        <div class="d_sctext">
                            <select id="school" class="chosen">
                                <option value="-1">请选择</option>
	                            <c:forEach var="sl" items="${schoolList }">
	                                <option value="${sl.sid}">${sl.name}</option>
	                            </c:forEach>
	                        </select>
                        </div>
                        
                    </div>
                    
                    <div class="d_scnOut" style="margin-left: 300px;margin-top: -40px;">
                        <div class="d_scname" >
                            <label for="name">卡号: </label>
                        </div>
                        <div class="d_sctext">
                            <input type="text" id="cardnum" />
                        </div>
                    </div>
                    
                    
                    <div style="margin-left: 600px;margin-top: -47px;">
                        <button onclick="assign();"
                            class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"
                            role="button" aria-disabled="false">
                            <span class="ui-button-text">分派</span>
                        </button>
                    </div>
                    
                    <div style="margin-top: 50px;font-weight: bold;">回收卡</div>
                    <div class="d_scnOut">
                        <div class="d_scname" >
                            <label for="name">卡号: </label>
                        </div>
                        <div class="d_sctext">
                            <input type="text" id="cardnumr" />
                        </div>
                    </div>     
                    <div style="margin-left: 600px;margin-top: -47px;">
                        <button onclick="recover();"
                            class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"
                            role="button" aria-disabled="false">
                            <span class="ui-button-text">回收</span>
                        </button>
                    </div>   
                </div>
                
            </div>
        </div>

    </div>

	<script type="text/javascript">
	$("#tabs").tabs();
	$(".chosen").chosen();
	// 分派
    function assign() {
        var sid = $('#school option:selected').val();
        if (-1 == sid) {
        	$().message("请选择学校");
        	return
        }
        var cardnum = $('#cardnum').val();//卡号
        if (null == cardnum || "" == cardnum) {
        	$().message("请输入卡号");
        	return
        }  
        if (null != cardnum && "" != cardnum && cardnum.length != 8) {
        	$().message("请输入正确的卡号");
        	return
        }
        var fun = function(data){
            if(1==data.s){
                 $().message("分派成功");
                 $('#cardnum').val("");
                 //$("#school").find("option[value='-1']").attr("selected",true);
            }else if (2 == data.s) {
            	$().message("该卡已分派给学校,请先回收");
            }else if (3 == data.s) {
            	$().message("该卡不在系统中,请先录入");
            }else{
                 $().message("分派失败");
            }
        };
        exeAjax(ajaxUrl('${aier_url}${aier_urijs}ic_manage_assign${aier_suffix}'), fun, 
                {"sid" :sid,"cardnum":cardnum});
    }
	
	// 回收卡
	function recover(){
		var cardnum = $('#cardnumr').val();//卡号
		if (null == cardnum || "" == cardnum) {
            $().message("请输入卡号");
            return
        }  
        if (null != cardnum && "" != cardnum && cardnum.length != 8) {
            $().message("请输入正确的卡号");
            return
        }
        var fun = function(data){
            if(1==data.s){
                 $().message("回收成功");
                 $('#cardnumr').val("");
            }else if (2 == data.s) {
                $().message("该卡不在系统中");
            }else{
                 $().message("回收失败");
            }
        };
        exeAjax(ajaxUrl('${aier_url}${aier_urijs}ic_manage_recover${aier_suffix}'), fun, 
                {"cardnum":cardnum});
	 }

	</script>
</body>
</html>